libxl: use libxl_domain_type enum with libxl__domain_suspend_common
authorIan Campbell <ian.campbell@citrix.com>
Mon, 18 Jul 2011 13:52:30 +0000 (14:52 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Mon, 18 Jul 2011 13:52:30 +0000 (14:52 +0100)
Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Acked-by: Ian Jackson <ian.jackson.citrix.com>
Committed-by: Ian Jackson <ian.jackson.citrix.com>
tools/libxl/libxl.c
tools/libxl/libxl_dom.c
tools/libxl/libxl_internal.h

index f7bd3b0293d18598179f039913aa6b62a9be1e66..4310a9f7df793aa79ea0e4ef37782ad10ca34d5f 100644 (file)
@@ -474,13 +474,13 @@ int libxl_domain_suspend(libxl_ctx *ctx, libxl_domain_suspend_info *info,
                          uint32_t domid, int fd)
 {
     libxl__gc gc = LIBXL_INIT_GC(ctx);
-    int hvm = LIBXL__DOMAIN_IS_TYPE(&gc,  domid, HVM);
+    libxl_domain_type type = libxl__domain_type(&gc, domid);
     int live = info != NULL && info->flags & XL_SUSPEND_LIVE;
     int debug = info != NULL && info->flags & XL_SUSPEND_DEBUG;
     int rc = 0;
 
-    rc = libxl__domain_suspend_common(&gc, domid, fd, hvm, live, debug);
-    if (!rc && hvm)
+    rc = libxl__domain_suspend_common(&gc, domid, fd, type, live, debug);
+    if (!rc && type == LIBXL_DOMAIN_TYPE_HVM)
         rc = libxl__domain_save_device_model(&gc, domid, fd);
     libxl__free_all(&gc);
     return rc;
index 3491736435989da3975548bee9f7ecc9456362eb..6c540a4aeec7f5b959a1feea2d0ab29ae4520659 100644 (file)
@@ -513,14 +513,26 @@ static int libxl__domain_suspend_common_callback(void *data)
 }
 
 int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
-               int hvm, int live, int debug)
+                                 libxl_domain_type type,
+                                 int live, int debug)
 {
     libxl_ctx *ctx = libxl__gc_owner(gc);
     int flags;
     int port;
     struct save_callbacks callbacks;
     struct suspendinfo si;
-    int rc = ERROR_FAIL;
+    int hvm, rc = ERROR_FAIL;
+
+    switch (type) {
+    case LIBXL_DOMAIN_TYPE_HVM:
+        hvm = 1;
+        break;
+    case LIBXL_DOMAIN_TYPE_PV:
+        hvm = 0;
+        break;
+    default:
+        return ERROR_INVAL;
+    }
 
     flags = (live) ? XCFLAGS_LIVE : 0
           | (debug) ? XCFLAGS_DEBUG : 0
index b2811f8532a3ecc78783933ad4771172fe57c57f..9570bc3be7953973ca05bf94a56f97a94b9dadf6 100644 (file)
@@ -199,7 +199,9 @@ _hidden int libxl__domain_restore_common(libxl__gc *gc, uint32_t domid,
                                          libxl_domain_build_info *info,
                                          libxl__domain_build_state *state,
                                          int fd);
-_hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd, int hvm, int live, int debug);
+_hidden int libxl__domain_suspend_common(libxl__gc *gc, uint32_t domid, int fd,
+                                         libxl_domain_type type,
+                                         int live, int debug);
 _hidden int libxl__domain_save_device_model(libxl__gc *gc, uint32_t domid, int fd);
 _hidden void libxl__userdata_destroyall(libxl__gc *gc, uint32_t domid);